package com.aaa.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/8/22 8:50
 * @description：
 * @modified By：
 * @version:
 */
//@Component  标识次类作为spring容器中的一个bean存在
//@Component
/*@Scope("singleton")*/
public class Teacher {
   // @Value("10000")
    private int id;
   // @Value("陈建")
    private String name;

    //@Value("900")
    private Double sal;

    public Teacher() {
        System.out.println("teacher实例化无参构造器");
    }

    /**
     * 构造柱如必备
     * @param id
     * @param name
     */
    public Teacher(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    /**
     * PostConstruct 注解的作用是在bean实例化之后进行增强处理
     */
    /*@PostConstruct
    public void initTeacher1(){
        System.out.println("老师bean实例化啦11111");
        if(this.sal<10000d){
            this.sal=10000d;
            System.out.println("收入不高");
        }
    }
    @PostConstruct
    public void initTeacher2(){
        System.out.println("老师bean实例化啦22222");
    }
    @PreDestroy
    public  void destoryTest(){
        System.out.println("我将要去见上帝了！");
    }*/
}
